const express = require('express')
const novelsRouter = require('./server/routes/novels')

const app = express()
app.use(express.json())

// 直接使用novels路由
app.use('/api/novels', novelsRouter)

// 错误处理
app.use((error, req, res, next) => {
  console.error('错误详情:', error)
  res.status(500).json({
    success: false,
    message: error.message,
    stack: error.stack
  })
})

const PORT = 3002
app.listen(PORT, () => {
  console.log(`直接路由测试服务器运行在 http://localhost:${PORT}`)
  console.log('测试地址: http://localhost:3002/api/novels')
})
